import request from '@/utils/request'

/**
 * 获取所有分类，不分页
 * @returns
 */
export const getAllCategoriesAPI = () => {
  return request({
    url: '/category/all',
    method: 'get',
  })
}

/**
 * 获取分类，分页
 */
export const getCategoryListAPI = (params) => {
  return request({
    url: '/category',
    method: 'get',
    params,
  })
}

/**
 * 创建分类
 */
export const createCategoryAPI = (data) => {
  return request({
    url: '/category',
    method: 'post',
    data,
  })
}

/**
 * 更新分类
 */
export const updateCategoryAPI = (data) => {
  return request({
    url: `/category/${data.id}`,
    method: 'put',
    data,
  })
}

/**
 * 删除分类
 */
export const deleteCategoryAPI = (id) => {
  return request({
    url: `/category/${id}`,
    method: 'delete',
  })
}
